Headscale快速搭建derper

484次阅读
没有评论

共计 1299 个字符,预计需要花费 4 分钟才能阅读完成。

提醒:本文最后更新于2025-06-23 14:32,文中所关联的信息可能已发生改变,请知悉!

官方新版本的Derp支持自签证书了

更新软件包,安装依赖

apt update && apt upgrade
apt install -y wget git openssl curl

安装最新版GO

wget https://go.dev/dl/go1.23.5.linux-amd64.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.23.5.linux-amd64.tar.gz

配置环境变量

export PATH=$PATH:/usr/local/go/bin
go version

echo "export PATH=$PATH:/usr/local/go/bin" >> /etc/profile
source /etc/profile

go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct

安装最新版Derper

安装

go install tailscale.com/cmd/derper@latest

拷贝二进制文件

mkdir /etc/derp/
cp ~/go/bin/derper /etc/derp/

查看是否拷贝成功

ls /etc/derp

生成Derper自签证书

DERP_IP=$(curl -s 4.ipw.cn)

openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout /root/${DERP_IP}.key -out /root/${DERP_IP}.crt -subj "/CN=${DERP_IP}" -addext "subjectAltName=IP:${DERP_IP}"

mv /root/${DERP_IP}.crt /etc/derp/
mv /root/${DERP_IP}.key /etc/derp/

载入systemd


DERP_IP=$(curl -s 4.ipw.cn)  # Fetch the IP dynamically

# Create the systemd service file with the dynamic IP using EOF
cat <<EOF > /etc/systemd/system/derp.service
[Unit]
Description=TS Derper
After=network.target
Wants=network.target

[Service]
User=root
Restart=always
ExecStart=/etc/derp/derper -hostname ${DERP_IP} -a :12345 -http-port -1 -certmode manual -certdir /etc/derp  --verify-clients
RestartPreventExitStatus=1

[Install]
WantedBy=multi-user.target
EOF

# Reload systemd to apply changes
systemctl daemon-reload

启动

systemctl enable derp
systemctl restart derp
systemctl status derp

正文完
 0
Monologue
版权声明:本站原创文章,由 Monologue 于2025-02-14发表,共计1299字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(没有评论)
验证码